﻿Imports DATA
Imports SERVICIOS

Public Class oFm_ListaPlanificaciones

    Private WithEvents oPlanificacion As New planificacion_data

    Private Sub oFm_ListaPlanificaciones_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
        Me.Dispose()
    End Sub

    Private Sub oFm_ListaPlanificaciones_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.TituloFormulario = "Listado de planificaciones"
        CrearGrilla()
        CargarPlanificaciones()
    End Sub

    Sub CrearGrilla()
      With oGr_datos
            .Cols_P = 3
            .Rows_P = 0
            .MaquillaGrilla()
            .ReadOnly = True
            .ColumnTextHeader(0, 85) = "Fecha"
            .ColumnTextHeader(1, 145) = "Curso"
            .ColumnTextHeader(2, 250) = "Uni. Aprendizaje"
            For i As Integer = 0 To .ColumnCount - 1
                .Columns(i).SortMode = DataGridViewColumnSortMode.Automatic
            Next
        End With
    End Sub

    Sub CargarPlanificaciones()
        With oGr_datos
            .Rows.Clear()
            Dim dt As DataTable = oPlanificacion.GetData
            Try
                .Rows_P = dt.Rows.Count
                Dim i As Integer = 0
                For Each x In dt.Rows
                    .TagMatrix(i, 0) = x.item(0)
                    .TextMatrix(i, 0) = Format(CDate(Mid(x.item(0), 1, 7)), "dd MMM yyyy")
                    .TextMatrix(i, 1) = x.item(1)
                    .TextMatrix(i, 2) = x.item(2)
                    i += 1
                Next
            Catch ex As Exception

            End Try
        End With
    End Sub

    Private Sub oPb_guardar_Click(sender As Object, e As EventArgs) Handles oPb_guardar.Click
        oFm_planificacion.ShowDialog()
        CargarPlanificaciones()
    End Sub

    Private Sub oPb_Salir_Click(sender As Object, e As EventArgs) Handles oPb_Salir.Click
        Me.Close()
    End Sub

 
    Private Sub oGr_datos_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles oGr_datos.CellDoubleClick
        With oGr_datos
            If .RowCount > 0 Then
                Dim codigo As String
                codigo = .TagMatrix(.Row, 0)
                oFm_planificacion._codigo = codigo
                oFm_planificacion.ShowDialog()
            End If
        End With
    End Sub
End Class
